$(function(){
function ajax(url,fnWin,fnFaild){
	var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	xhr.open("GET",url,true);
	xhr.send();
	xhr.onreadystatechange = function(){
		if(xhr.readyState ==4 && xhr.status == 200){
			if(typeof fnWin == "function"){
				fnWin(xhr.responseText);
			}
		}else{
			if(typeof fnFaild == "function"){
				fnFaild();
			}
		}
	}
}
//商品页商品图片及其他介绍
$.ajax("../json/goods.json")
.then(function(json){
	var html ="";
	for(var i = 0 ; i < json.length ; i++){
		html +=`<div class = "pic" data-good-id="id">
					<a href="details.html"><img src = "${json[i].img}" alt=""/></a>
					<p class = "hei"><a href="">${json[i].name1}</a></p>
					<span> ${json[i].price1}<i>${json[i].price2} </i> </span>
					<ul class= "goodInfo">
						<input class= "cha" type="button" />
						<input type="button" value="收藏" />
						<input type="button" value="对比" />
					</ul>
				</div>`		
	}
	$(".much").html(html);	
})
})